Assembly 8086 : How to Make thanks with a loop and video memory
I need a program that show at the center the write "Thanks" with heart symbols in left and right side of the text, but the hearts with red color and the text with green color.
I have now this code:
mov ax, 0B800h
mov es, ax
mov di,spiazz
mov byte ptr es:[di+0], ' '
mov byte ptr es:[di+2], ' '
mov byte ptr es:[di+4], ' '
mov byte ptr es:[di+1], 20h
mov byte ptr es:[di+3], 70h
mov byte ptr es:[di+5], 40h
With a similar code like this, I need to show an "heart(symbol)Thanks heart(symbol)";
but with the hearts red and the text green.
Thank you in advance
assembly x86-16
|
show 1 more comment
I need a program that show at the center the write "Thanks" with heart symbols in left and right side of the text, but the hearts with red color and the text with green color.
I have now this code:
mov ax, 0B800h
mov es, ax
mov di,spiazz
mov byte ptr es:[di+0], ' '
mov byte ptr es:[di+2], ' '
mov byte ptr es:[di+4], ' '
mov byte ptr es:[di+1], 20h
mov byte ptr es:[di+3], 70h
mov byte ptr es:[di+5], 40h
With a similar code like this, I need to show an "heart(symbol)Thanks heart(symbol)";
but with the hearts red and the text green.
Thank you in advance
assembly x86-16
1
You can mov-immediate a whole word, instead of the bytes separately. likemov word ptr es:[di+2], (20h<<8) + ' '. That's much more efficient than 2 separate byte-store instructions.
– Peter Cordes
Nov 20 '18 at 20:34
thanks Peter Cordes
– Blog Everywhere YAT the blogge
Nov 20 '18 at 20:37
1
Which part are you having trouble with? You already know how to store into video memory. And how do you want to make a loop? Do you want to copy from somewhere else? If your data is immediate values, you can't loop because you need to store a different value in each instruction.
– Peter Cordes
Nov 20 '18 at 20:37
Can you make an example, please?
– Blog Everywhere YAT the blogge
Nov 20 '18 at 21:07
@PeterCordes Thanks too much
– Blog Everywhere YAT the blogge
Nov 20 '18 at 21:11
|
show 1 more comment
I need a program that show at the center the write "Thanks" with heart symbols in left and right side of the text, but the hearts with red color and the text with green color.
I have now this code:
mov ax, 0B800h
mov es, ax
mov di,spiazz
mov byte ptr es:[di+0], ' '
mov byte ptr es:[di+2], ' '
mov byte ptr es:[di+4], ' '
mov byte ptr es:[di+1], 20h
mov byte ptr es:[di+3], 70h
mov byte ptr es:[di+5], 40h
With a similar code like this, I need to show an "heart(symbol)Thanks heart(symbol)";
but with the hearts red and the text green.
Thank you in advance
assembly x86-16
I need a program that show at the center the write "Thanks" with heart symbols in left and right side of the text, but the hearts with red color and the text with green color.
I have now this code:
mov ax, 0B800h
mov es, ax
mov di,spiazz
mov byte ptr es:[di+0], ' '
mov byte ptr es:[di+2], ' '
mov byte ptr es:[di+4], ' '
mov byte ptr es:[di+1], 20h
mov byte ptr es:[di+3], 70h
mov byte ptr es:[di+5], 40h
With a similar code like this, I need to show an "heart(symbol)Thanks heart(symbol)";
but with the hearts red and the text green.
Thank you in advance
assembly x86-16
assembly x86-16
edited Nov 20 '18 at 20:32
Peter Cordes
119k16181307
119k16181307
asked Nov 20 '18 at 20:25
Blog Everywhere YAT the blogge
1
1
1
You can mov-immediate a whole word, instead of the bytes separately. likemov word ptr es:[di+2], (20h<<8) + ' '. That's much more efficient than 2 separate byte-store instructions.
– Peter Cordes
Nov 20 '18 at 20:34
thanks Peter Cordes
– Blog Everywhere YAT the blogge
Nov 20 '18 at 20:37
1
Which part are you having trouble with? You already know how to store into video memory. And how do you want to make a loop? Do you want to copy from somewhere else? If your data is immediate values, you can't loop because you need to store a different value in each instruction.
– Peter Cordes
Nov 20 '18 at 20:37
Can you make an example, please?
– Blog Everywhere YAT the blogge
Nov 20 '18 at 21:07
@PeterCordes Thanks too much
– Blog Everywhere YAT the blogge
Nov 20 '18 at 21:11
|
show 1 more comment
1
You can mov-immediate a whole word, instead of the bytes separately. likemov word ptr es:[di+2], (20h<<8) + ' '. That's much more efficient than 2 separate byte-store instructions.
– Peter Cordes
Nov 20 '18 at 20:34
thanks Peter Cordes
– Blog Everywhere YAT the blogge
Nov 20 '18 at 20:37
1
Which part are you having trouble with? You already know how to store into video memory. And how do you want to make a loop? Do you want to copy from somewhere else? If your data is immediate values, you can't loop because you need to store a different value in each instruction.
– Peter Cordes
Nov 20 '18 at 20:37
Can you make an example, please?
– Blog Everywhere YAT the blogge
Nov 20 '18 at 21:07
@PeterCordes Thanks too much
– Blog Everywhere YAT the blogge
Nov 20 '18 at 21:11
1
1
You can mov-immediate a whole word, instead of the bytes separately. like
mov word ptr es:[di+2], (20h<<8) + ' '. That's much more efficient than 2 separate byte-store instructions.– Peter Cordes
Nov 20 '18 at 20:34
You can mov-immediate a whole word, instead of the bytes separately. like
mov word ptr es:[di+2], (20h<<8) + ' '. That's much more efficient than 2 separate byte-store instructions.– Peter Cordes
Nov 20 '18 at 20:34
thanks Peter Cordes
– Blog Everywhere YAT the blogge
Nov 20 '18 at 20:37
thanks Peter Cordes
– Blog Everywhere YAT the blogge
Nov 20 '18 at 20:37
1
1
Which part are you having trouble with? You already know how to store into video memory. And how do you want to make a loop? Do you want to copy from somewhere else? If your data is immediate values, you can't loop because you need to store a different value in each instruction.
– Peter Cordes
Nov 20 '18 at 20:37
Which part are you having trouble with? You already know how to store into video memory. And how do you want to make a loop? Do you want to copy from somewhere else? If your data is immediate values, you can't loop because you need to store a different value in each instruction.
– Peter Cordes
Nov 20 '18 at 20:37
Can you make an example, please?
– Blog Everywhere YAT the blogge
Nov 20 '18 at 21:07
Can you make an example, please?
– Blog Everywhere YAT the blogge
Nov 20 '18 at 21:07
@PeterCordes Thanks too much
– Blog Everywhere YAT the blogge
Nov 20 '18 at 21:11
@PeterCordes Thanks too much
– Blog Everywhere YAT the blogge
Nov 20 '18 at 21:11
|
show 1 more comment
1 Answer
1
active
oldest
votes
There are many ways to achieve this. Below is one of these:
mov ax, 0B800h ;Points to the 80x25 text screen
mov es, ax
mov di, (13-1)*160+(37-1)*2 ;Print At(37,13); //Column 37, Row 13
mov si, msg
cld ;This makes SI and DI move f o r w a r d as is needed
mov ax, 0403h ;AL=3 (heart character) AH=04h (RedOnBlack)
push ax ;(1) Preserve on the stack
LL:
stosw
mov ah, 02h ;GreenOnBlack
lodsb
cmp al, 0 ;Message was zero-terminated
jne LL ;Terminator not yet reached
pop ax ;(1) Restore from the stack
stosw ;This outputs the second heart character
...
msg db 'Thanks', 0
Do pay special attention to the comments! Don't just copy-paste it.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53400999%2fassembly-8086-how-to-make-thanks-with-a-loop-and-video-memory%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
There are many ways to achieve this. Below is one of these:
mov ax, 0B800h ;Points to the 80x25 text screen
mov es, ax
mov di, (13-1)*160+(37-1)*2 ;Print At(37,13); //Column 37, Row 13
mov si, msg
cld ;This makes SI and DI move f o r w a r d as is needed
mov ax, 0403h ;AL=3 (heart character) AH=04h (RedOnBlack)
push ax ;(1) Preserve on the stack
LL:
stosw
mov ah, 02h ;GreenOnBlack
lodsb
cmp al, 0 ;Message was zero-terminated
jne LL ;Terminator not yet reached
pop ax ;(1) Restore from the stack
stosw ;This outputs the second heart character
...
msg db 'Thanks', 0
Do pay special attention to the comments! Don't just copy-paste it.
add a comment |
There are many ways to achieve this. Below is one of these:
mov ax, 0B800h ;Points to the 80x25 text screen
mov es, ax
mov di, (13-1)*160+(37-1)*2 ;Print At(37,13); //Column 37, Row 13
mov si, msg
cld ;This makes SI and DI move f o r w a r d as is needed
mov ax, 0403h ;AL=3 (heart character) AH=04h (RedOnBlack)
push ax ;(1) Preserve on the stack
LL:
stosw
mov ah, 02h ;GreenOnBlack
lodsb
cmp al, 0 ;Message was zero-terminated
jne LL ;Terminator not yet reached
pop ax ;(1) Restore from the stack
stosw ;This outputs the second heart character
...
msg db 'Thanks', 0
Do pay special attention to the comments! Don't just copy-paste it.
add a comment |
There are many ways to achieve this. Below is one of these:
mov ax, 0B800h ;Points to the 80x25 text screen
mov es, ax
mov di, (13-1)*160+(37-1)*2 ;Print At(37,13); //Column 37, Row 13
mov si, msg
cld ;This makes SI and DI move f o r w a r d as is needed
mov ax, 0403h ;AL=3 (heart character) AH=04h (RedOnBlack)
push ax ;(1) Preserve on the stack
LL:
stosw
mov ah, 02h ;GreenOnBlack
lodsb
cmp al, 0 ;Message was zero-terminated
jne LL ;Terminator not yet reached
pop ax ;(1) Restore from the stack
stosw ;This outputs the second heart character
...
msg db 'Thanks', 0
Do pay special attention to the comments! Don't just copy-paste it.
There are many ways to achieve this. Below is one of these:
mov ax, 0B800h ;Points to the 80x25 text screen
mov es, ax
mov di, (13-1)*160+(37-1)*2 ;Print At(37,13); //Column 37, Row 13
mov si, msg
cld ;This makes SI and DI move f o r w a r d as is needed
mov ax, 0403h ;AL=3 (heart character) AH=04h (RedOnBlack)
push ax ;(1) Preserve on the stack
LL:
stosw
mov ah, 02h ;GreenOnBlack
lodsb
cmp al, 0 ;Message was zero-terminated
jne LL ;Terminator not yet reached
pop ax ;(1) Restore from the stack
stosw ;This outputs the second heart character
...
msg db 'Thanks', 0
Do pay special attention to the comments! Don't just copy-paste it.
answered Nov 25 '18 at 20:57
Sep Roland
11.7k21945
11.7k21945
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53400999%2fassembly-8086-how-to-make-thanks-with-a-loop-and-video-memory%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
You can mov-immediate a whole word, instead of the bytes separately. like
mov word ptr es:[di+2], (20h<<8) + ' '. That's much more efficient than 2 separate byte-store instructions.– Peter Cordes
Nov 20 '18 at 20:34
thanks Peter Cordes
– Blog Everywhere YAT the blogge
Nov 20 '18 at 20:37
1
Which part are you having trouble with? You already know how to store into video memory. And how do you want to make a loop? Do you want to copy from somewhere else? If your data is immediate values, you can't loop because you need to store a different value in each instruction.
– Peter Cordes
Nov 20 '18 at 20:37
Can you make an example, please?
– Blog Everywhere YAT the blogge
Nov 20 '18 at 21:07
@PeterCordes Thanks too much
– Blog Everywhere YAT the blogge
Nov 20 '18 at 21:11